package yxy.apple.util;

import org.apache.commons.text.RandomStringGenerator;

public class RandomStringUtility {

	static char[] NUMERIC_CHARSET = { '0', '9' };//
	static char[] LOWERCASE_CHARSET = { 'a', 'z' };
	static char[] UPPERCASE_CHARSET = { 'A', 'Z' };

	/** 小写 数字 混合 */
	static public String randomLowerNumeric(int length) {
		RandomStringGenerator generator1 = new RandomStringGenerator.Builder()//
				.withinRange(NUMERIC_CHARSET, LOWERCASE_CHARSET).build();
		return generator1.generate(length);
	}

	/** 小写字母 */
	static public String randomLowerCase(int length) {
		RandomStringGenerator generator1 = new RandomStringGenerator.Builder()//
				.withinRange(LOWERCASE_CHARSET).build();
		return generator1.generate(length);
	}

	/** 大写 数字 混合 */
	static public String randomUpperNumeric(int length) {
		RandomStringGenerator generator1 = new RandomStringGenerator.Builder()//
				.withinRange(NUMERIC_CHARSET, UPPERCASE_CHARSET).build();
		return generator1.generate(length);
	}

	/** 大写字母 */
	static public String randomUpperCase(int length) {
		RandomStringGenerator generator1 = new RandomStringGenerator.Builder()//
				.withinRange(UPPERCASE_CHARSET).build();
		return generator1.generate(length);
	}

	/** 大写 小写 混合 */
	static public String randomAlpha(int length) {
		RandomStringGenerator generator1 = new RandomStringGenerator.Builder()//
				.withinRange(LOWERCASE_CHARSET, UPPERCASE_CHARSET).build();
		return generator1.generate(length);
	}

	/** 大写 小写 数字 混合 */
	static public String randomAlphaNumeric(int length) {
		RandomStringGenerator generator1 = new RandomStringGenerator.Builder()//
				.withinRange(NUMERIC_CHARSET, LOWERCASE_CHARSET, UPPERCASE_CHARSET).build();
		return generator1.generate(length);
	}
}
